package com.sky.mapper;

import com.github.pagehelper.Page;
import com.sky.annotation.AutoFill;
import com.sky.dto.SetmealPageQueryDTO;
import com.sky.entity.Category;
import com.sky.entity.Setmeal;
import com.sky.enumeration.OperationType;
import com.sky.vo.SetmealVO;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

@Mapper
public interface setMealMapper {
    /**
     * 根据category_id来查询setmeal表是否关联要删除的分类
     */
    @Select("select count(*) from setmeal where category_id=#{id}")
    public Integer cheakById(Integer id);

    @Select("select * from setmeal where category_id=#{id}")
    List<Setmeal> cheakByCategoryId(String id);
    Page<SetmealVO> select(SetmealPageQueryDTO setmealPageQueryDTO);

    @AutoFill(OperationType.INSERT)
    void insert(Setmeal setmeal);

    @Select("select * from setmeal where id=#{id}")
    SetmealVO selectById(Integer id);

    void delete(List<Integer> ids);

    @AutoFill(OperationType.UPDATE)
    void update(Setmeal setmeal);

    @Update("update setmeal set status=#{status} where id=#{id}")
    void set(Integer status, Integer id);
}
